﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LPY.LeHealth.DTO;

namespace LPY.LeHealth.DAL
{
     using ServiceStack.OrmLite;
    public class tbdal : GenericBaseDAL<tibao>
    {
        public long Add(tibao tb)
        {
            var uid = DbConnection.Insert<tibao>(tb, selectIdentity: true);
            return uid;
        }
        /// <summary>
        /// 显示体检报告表
        /// </summary>
        /// <returns></returns>
        public List<tibao> GetAllComboType(int id)
        {
            using (var cnn = DbConnection)
            {

                var rtv = cnn.Select<tibao>().Where(n => n.examinationpeopleid == id).ToList();
                return rtv;
            }
        }

        public List<Object> GetReportList()
        {
            using (var cnn=DbConnection)
            {
                var sql = cnn.From<tibaoDTO>()
                    .LeftJoin<tibaoDTO, UserDTO>((t, u) => t.UserId == u.Id)
                    .Select<tibaoDTO, UserDTO>((t, u) => new
                    {
                        t.tbid,
                        t.tbname,
                        t.tbstate,
                        u.Name
                    });//.Where(m=>m.UserId==id );

                return cnn.Select<object>(sql);
            }
        }
    }
}
